package cn.itcast.web.servlet;

import cn.itcast.domain.ChangeList;
import cn.itcast.service.ChangeListService;
import cn.itcast.service.impl.ChangeListServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/findChangeListByIdbServlet")
public class FindChangeListByIdbServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置编码
        request.setCharacterEncoding("utf-8");
        //1获取id,uid
        String id = request.getParameter("id");
        String uid = request.getParameter("uid");
        String uname = request.getParameter("uname");
        /*2调用service查询
         *
         * */
        ChangeListService service=new ChangeListServiceImpl();
        ChangeList changelist=service.findChangeListByIdb(id);
        /*3将changelist存入request,还有uid
         *
         * */
        request.setAttribute("changelist",changelist);
        request.setAttribute("uid",uid);
        request.setAttribute("uname",uname);
        /*4转发到ChangeListaupdate.jsp
         * */
        request.getRequestDispatcher("/ChangeListbupdate.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
